<?php
namespace Tbf\Util;
/**
 * @deprecated
 */
class tbfLoadProject extends tbfOject
{
    public $classes = array();
    public function loadAllPhp()
    {
        if (getCallNum('tbfLoadProject_LoadAllPhp')>1) {
            return;
        }
        import('kernel.utility.tbfPath');
        $file = tbfPath::listFileR(appPath::$root);
        foreach ($file as $v1) {
            if (strpos($v1,'/test')!==false) {
                continue;
            }
            if (strpos($v1,'/vendor/')!==false) {
                continue;
            }
            $ext = tbfPath::getExt($v1);
            if ($ext!=='php') {
                continue;
            }
            appPath::importByPath($v1);
        }
        $this->classes = get_declared_classes();
    }
    public function getAllSubclass($className)
    {
        $this->loadAllPhp();
        $output = array();
        foreach ($this->classes as $class) {
            if (!is_subclass_of($class,$className)) {
                continue;
            }
            $output[] = $class;
        }

        return $output;
    }
    public function getAllModel()
    {
        return $this->getAllSubclass('model');
    }
    public function getAllController()
    {
        return $this->getAllSubclass('controller');
    }
}//class
